package com.sweet.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RouteConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route(
                "route_path1", r -> r.path("/backend").uri("https://juejin.cn")
        ).route(
                "route_path2", r -> r.path("/guonei").uri("http://news.baidu.com")
        ).route(
                "route_path3", r -> r.path("/guoji").uri("http://news.baidu.com")
        ).build();
        return routes.build();
    }
}
